package com.clarte.incometype.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.clarte.common.dao.BaseDao;
import com.clarte.model.IncomeType;
@Service("incomeTypeService")
@Transactional
public class IncomeTypeServiceImpl implements IncomeTypeService {
	@Resource(name="baseDao")
	private BaseDao<IncomeType, Integer> baseDao;
	
	@Override
	public void addIncomeType(IncomeType incomeType) {
		baseDao.save(incomeType);
	}

	@Override
	public void delIncomeType(Integer... id) {
		baseDao.delete(id);
	}

	@Override
	public void editIncomeType(IncomeType incomeType) {
		baseDao.update(incomeType);
	}

	@Override
	public List<IncomeType> findAll() {
		return baseDao.findAll();
	}

	@Override
	public boolean isExist(String code) {
		String hql = "select count(*) from IncomeType t where t.code = ?";
		long l = baseDao.getTotal(hql, new String[]{code});
		return l > 0;
	}

}
